package com.stars.home.adapter

import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.qmuiteam.qmui.kotlin.onClick
import com.stars.home.R
import com.stars.home.activity.ReceivedDetailsActivity
import com.stars.home.databinding.ItemHomeFristBinding
import com.stars.home.model.TechnicianOrder
import com.stars.home.utils.DayUtils
import com.stars.home.vmodel.HomeFirstVModel
import com.trailer.base.base.BAdapter
import com.trailer.base.utils.B
import com.trailer.base.utils.UiSwitch

class HomeFristAdapter(var vm: HomeFirstVModel) : BAdapter<TechnicianOrder, BaseDataBindingHolder<ItemHomeFristBinding>>(R.layout.item_home_frist) {
    override fun convert(holder: BaseDataBindingHolder<ItemHomeFristBinding>, item: TechnicianOrder) {
        holder.dataBinding?.item = item
        holder.dataBinding?.vm=vm
        holder.dataBinding?.position=holder.adapterPosition

        //设置服务列表
        var  adapter=ServerOrderAdapter()
        holder.dataBinding?.recyclerServer?.adapter=adapter
        adapter.addData(item.serviceInfo)

        adapter.setOnItemClickListener { adapter, view, position ->

            UiSwitch.bundle(
                context(),
                ReceivedDetailsActivity::class.java, B().putString("id", item.id).ok()
            )
        }


        if(null!=item.serviceTime) {
            holder.dataBinding?.tvTime?.text = DayUtils.getToday(item.serviceTime)
        }else{
            holder.dataBinding?.tvTime?.text=null
        }

        holder.dataBinding?.ll?.onClick {


            UiSwitch.bundle(
                context(),
                ReceivedDetailsActivity::class.java, B().putString("id", item.id).ok()
            )


//            if(item.technicianStatus==-1||item.technicianStatus==0||item.technicianStatus==5){
//
//                UiSwitch.bundle(
//                    context(),
//                    ReceivedDetailsActivity::class.java, B().putString("id", item.id).ok()
//                )
//            }else{
//
//                UiSwitch.bundle(
//                    context(),
//                    OrderDetailsActivity::class.java, B().putString("id", item.id).ok()
//                )
//            }

        }




    }
}
